/*
 * Copyright 2012 Finbudget.com
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package finbudgettable.client.ui.grid.dnd;

import java.util.ArrayList;
import java.util.List;

public class DragAndDropController {

    private final List<DropTarget<?>> dropTargetList = new ArrayList<DropTarget<?>>();

    public void addDropZone(DropTarget<?> dropTarget) {
        dropTargetList.add(dropTarget);
    }

    @SuppressWarnings({ "rawtypes", "unchecked" })
	public void fireDragStartEvent(Draggable draggable) {
        for (DropTarget<?> zone : dropTargetList) {
            zone.onDragStart(draggable);
        }
    }

    @SuppressWarnings({ "rawtypes", "unchecked" })
	public void fireDragEvent(Draggable draggable, int x, int y) {
        for (DropTarget<?> zone : dropTargetList) {
            zone.onDrag(draggable, x, y);
        }
    }

    @SuppressWarnings({ "rawtypes", "unchecked" })
	public void fireDragEndEvent(Draggable draggable) {
        for (DropTarget<?> target : dropTargetList) {
            target.onDragEnd(draggable);
        }
    }
}
